package com.wpzf.zxhc.service.impl;

import com.monitorjbl.xlsx.StreamingReader;
import com.wpzf.zxhc.domain.TbJctjxxbDao;
import com.wpzf.zxhc.mapper.JdfkStatisticsMapper;
import com.wpzf.zxhc.service.JdfkStatisticsService;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.multipart.MultipartFile;

import java.io.Console;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class JdfkStatisticsServiceImpl implements JdfkStatisticsService {
    @Autowired
    JdfkStatisticsMapper jdfkStatisticsMapper;

    @Override
    public List<Map<String, Object>> getXzqSheng() {
        return jdfkStatisticsMapper.getXzqSheng();
    }

    @Override
    public List<Map<String, Object>> getXzqShi(Map<String, Object> parms) {
        return jdfkStatisticsMapper.getXzqShi(parms);
    }

    @Override
    public List<Map<String, Object>> getXzqXian(Map<String, Object> parms) {
        return jdfkStatisticsMapper.getXzqXian(parms);
    }

    @Override
    public List<Map<String, Object>> getPdlx() {
        return jdfkStatisticsMapper.getPdlx();
    }

    @Override
    public List<Map<String, Object>> getHcjgsm() {
        return jdfkStatisticsMapper.getHcjgsm();
    }

    @Override
    public List<Map<String, Object>> getJdfk(Map<String, Object> parms) {
        return jdfkStatisticsMapper.getJdfk(parms);
    }

    @Override
    public Integer getJdfkCount(Map<String, Object> parms) {
        return jdfkStatisticsMapper.getJdfkCount(parms);
    }

    @Value("${tempath}")
    public String tempath;

    @Override
    public String uploadFile(MultipartFile mFile) {
        String fileUrl = tempath + "\\" + mFile.getOriginalFilename();
        try {
            //使用此方法保存必须要绝对路径且文件夹必须已存在,否则报错
            File localFile = new File(fileUrl);
            File fParentlocaltion = localFile.getParentFile();
            if (!fParentlocaltion.exists()) { //判断文件父目录是否存在
                fParentlocaltion.mkdirs();
            }
            mFile.transferTo(localFile);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
        return fileUrl;
    }

    @Override
    public Boolean dealWithUpData(String sXzq, String sYear, String sMonth, String sUpType) {
        try {
            if (sUpType.equals("覆盖")) {
                /* 覆盖=>删除重复数据**/
                int nRepeatCount = jdfkStatisticsMapper.getRepeatDataCount(sXzq, sYear, sMonth);
                if (nRepeatCount > 0) {
                    int nDel = jdfkStatisticsMapper.delRepeatData(sXzq, sYear, sMonth);
                    if (nDel == nRepeatCount)
                        return true;
                    else
                        return false;
                }
                return true;
            } else if (sUpType.equals("追加")) {
                return true;
            }
            return false;
        } catch (Exception ex) {
            return false;
        }
    }

    @Override
    public String importDataByExcel(String sFilePath, String sYear, String sMonth) {
        try {
            FileInputStream in = new FileInputStream(sFilePath);
            Workbook wk = StreamingReader.builder()
                    .rowCacheSize(100)  //缓存到内存中的行数，默认是10
                    .bufferSize(4096)  //读取资源时，缓存到内存的字节大小，默认是1024
                    .open(in);  //打开资源，必须，可以是InputStream或者是File，注意：只能打开XLSX格式的文件
            Sheet sheet = wk.getSheetAt(0);
            List<TbJctjxxbDao> jctjxxbDaoList = new ArrayList<>();
            int nStartRow = 3;
            int nRow = 0;
            //遍历所有的行
            for (Row row : sheet) {
                if (nRow++ < nStartRow)
                    continue;
                TbJctjxxbDao tbJctjxxb = new TbJctjxxbDao();
                tbJctjxxb.setXzqdmSheng(row.getCell(0).getStringCellValue());
                tbJctjxxb.setXzqdmXian(row.getCell(1).getStringCellValue());
                tbJctjxxb.setXzqSheng(row.getCell(2).getStringCellValue());
                tbJctjxxb.setXzqShi(row.getCell(3).getStringCellValue());
                tbJctjxxb.setXzqXian(row.getCell(4).getStringCellValue());
                tbJctjxxb.setTbbh(row.getCell(5).getStringCellValue());
                tbJctjxxb.setJcbh(row.getCell(6).getStringCellValue());
                tbJctjxxb.setYdMonth(row.getCell(7).getStringCellValue());
                tbJctjxxb.setXfsj(row.getCell(8).getStringCellValue());
                tbJctjxxb.setPdlx(row.getCell(9).getStringCellValue());
                tbJctjxxb.setZphlxjc(row.getCell(10).getStringCellValue());
                tbJctjxxb.setYxzpdl(row.getCell(11).getStringCellValue());
                tbJctjxxb.setHcjgsm(row.getCell(12).getStringCellValue());
                tbJctjxxb.setTjmj(Float.parseFloat((row.getCell(13).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(13).getStringCellValue()));
                tbJctjxxb.setThdkmj(Float.parseFloat((row.getCell(14).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(14).getStringCellValue()));
                tbJctjxxb.setThdkgdmj(Float.parseFloat((row.getCell(15).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(15).getStringCellValue()));
                tbJctjxxb.setThdkzjbntmj(Float.parseFloat((row.getCell(16).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(16).getStringCellValue()));
                tbJctjxxb.setThnydmj(Float.parseFloat((row.getCell(17).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(17).getStringCellValue()));
                tbJctjxxb.setThdkstmj(Float.parseFloat((row.getCell(18).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(18).getStringCellValue()));
                tbJctjxxb.setThstbhhxmj(Float.parseFloat((row.getCell(19).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(19).getStringCellValue()));
                tbJctjxxb.setTbdkmj(Float.parseFloat((row.getCell(20).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(20).getStringCellValue()));
                tbJctjxxb.setTbdkqzgdmj(Float.parseFloat((row.getCell(21).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(21).getStringCellValue()));
                tbJctjxxb.setTbdkqzjbntmj(Float.parseFloat((row.getCell(22).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(22).getStringCellValue()));
                tbJctjxxb.setTbnydmj(Float.parseFloat((row.getCell(23).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(23).getStringCellValue()));
                tbJctjxxb.setTbdkstmj(Float.parseFloat((row.getCell(24).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(24).getStringCellValue()));
                tbJctjxxb.setTbdkstbhhxmj(Float.parseFloat((row.getCell(25).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(25).getStringCellValue()));
                tbJctjxxb.setHfsjytmc1j(row.getCell(26).getStringCellValue());
                tbJctjxxb.setHfsjytmc2j(row.getCell(27).getStringCellValue());
                tbJctjxxb.setHfpdyjsm(row.getCell(28).getStringCellValue());
                tbJctjxxb.setWflxmc1j(row.getCell(29).getStringCellValue());
                tbJctjxxb.setWflxmc2j(row.getCell(30).getStringCellValue());
                tbJctjxxb.setWflxmc3j(row.getCell(31).getStringCellValue());
                tbJctjxxb.setWflxmc4j(row.getCell(32).getStringCellValue());
                tbJctjxxb.setWfsjytmc1j(row.getCell(33).getStringCellValue());
                tbJctjxxb.setWfsjytmc2j(row.getCell(34).getStringCellValue());
                tbJctjxxb.setWfpdyjsm(row.getCell(35).getStringCellValue());
                tbJctjxxb.setClfs(row.getCell(36).getStringCellValue());
                tbJctjxxb.setLabh(row.getCell(37).getStringCellValue());
                tbJctjxxb.setZglsqk1(row.getCell(38).getStringCellValue());
                tbJctjxxb.setHftdymmj(Float.parseFloat((row.getCell(39).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(39).getStringCellValue()));
                tbJctjxxb.setFgdwmj(Float.parseFloat((row.getCell(40).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(40).getStringCellValue()));
                tbJctjxxb.setCcfgzjbntmj(Float.parseFloat((row.getCell(41).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(41).getStringCellValue()));
                tbJctjxxb.setCcfgzstbhhxmj(Float.parseFloat((row.getCell(42).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(42).getStringCellValue()));
                tbJctjxxb.setCfdwqk(row.getCell(43).getStringCellValue());
                tbJctjxxb.setZglsqk2(row.getCell(44).getStringCellValue());
                tbJctjxxb.setYjdbm(row.getCell(45).getStringCellValue());
                tbJctjxxb.setQtsjytmc1j(row.getCell(46).getStringCellValue());
                tbJctjxxb.setQtsjytmc2j(row.getCell(47).getStringCellValue());
                tbJctjxxb.setWfxwbh(row.getCell(48).getStringCellValue());
                tbJctjxxb.setWfxwSjytmc(row.getCell(49).getStringCellValue());
                tbJctjxxb.setSfjjxm(row.getCell(50).getStringCellValue());
                tbJctjxxb.setSfyfyhfzzdyqxyjsdylwsss(row.getCell(51).getStringCellValue());
                tbJctjxxb.setSfbzxajzf(row.getCell(52).getStringCellValue());
                tbJctjxxb.setWfxwXmlxmc(row.getCell(53).getStringCellValue());
                tbJctjxxb.setWfXmmc(row.getCell(54).getStringCellValue());
                tbJctjxxb.setWfXmzt(row.getCell(55).getStringCellValue());
                tbJctjxxb.setWfLxpzjg(row.getCell(56).getStringCellValue());
                tbJctjxxb.setWfLxpzwh(row.getCell(57).getStringCellValue());
                tbJctjxxb.setSfxzlzgdjf(row.getCell(58).getStringCellValue());
                tbJctjxxb.setSfwhzj(row.getCell(59).getStringCellValue());
                tbJctjxxb.setSfdpf(row.getCell(60).getStringCellValue());
                tbJctjxxb.setXgsj(row.getCell(61).getStringCellValue());
                tbJctjxxb.setPwgs(row.getCell(62).getStringCellValue());
                tbJctjxxb.setNydzypzwh(row.getCell(63).getStringCellValue());
                tbJctjxxb.setNydzypwly(row.getCell(64).getStringCellValue());
                tbJctjxxb.setNydzypzmj(row.getCell(65).getStringCellValue());
                tbJctjxxb.setNydzypzjg(row.getCell(66).getStringCellValue());
                tbJctjxxb.setNydzypzrq(row.getCell(67).getStringCellValue());
                tbJctjxxb.setZjggpzwh(row.getCell(68).getStringCellValue());
                tbJctjxxb.setZjggpwly(row.getCell(69).getStringCellValue());
                tbJctjxxb.setZjggpzmj(row.getCell(70).getStringCellValue());
                tbJctjxxb.setZjggpzjg(row.getCell(71).getStringCellValue());
                tbJctjxxb.setZjggpzrq(row.getCell(72).getStringCellValue());
                tbJctjxxb.setGkfqdpzwh(row.getCell(73).getStringCellValue());
                tbJctjxxb.setGkfqdpwly(row.getCell(74).getStringCellValue());
                tbJctjxxb.setGkfqdpzmj(row.getCell(75).getStringCellValue());
                tbJctjxxb.setGkfqdpzjg(row.getCell(76).getStringCellValue());
                tbJctjxxb.setGkfqdpzrq(row.getCell(77).getStringCellValue());
                tbJctjxxb.setBdcqzspzwh(row.getCell(78).getStringCellValue());
                tbJctjxxb.setBdcqzspwly(row.getCell(79).getStringCellValue());
                tbJctjxxb.setBdcqzspzmj(row.getCell(80).getStringCellValue());
                tbJctjxxb.setBdcqzspzjg(row.getCell(81).getStringCellValue());
                tbJctjxxb.setBdcqzspzrq(row.getCell(82).getStringCellValue());
                tbJctjxxb.setSsnydpzwh(row.getCell(83).getStringCellValue());
                tbJctjxxb.setSsnydpwly(row.getCell(84).getStringCellValue());
                tbJctjxxb.setSsnydpzmj(row.getCell(85).getStringCellValue());
                tbJctjxxb.setSsnydpzjg(row.getCell(86).getStringCellValue());
                tbJctjxxb.setSsnydpzrq(row.getCell(87).getStringCellValue());
                tbJctjxxb.setTdzzyspzwh(row.getCell(88).getStringCellValue());
                tbJctjxxb.setTdzzyspwly(row.getCell(89).getStringCellValue());
                tbJctjxxb.setTdzzyspzmj(row.getCell(90).getStringCellValue());
                tbJctjxxb.setTdzzyspzjg(row.getCell(91).getStringCellValue());
                tbJctjxxb.setTdzzyspzrq(row.getCell(92).getStringCellValue());
                tbJctjxxb.setQtpzwh(row.getCell(93).getStringCellValue());
                tbJctjxxb.setQtpwly(row.getCell(94).getStringCellValue());
                tbJctjxxb.setQtpzmj(row.getCell(95).getStringCellValue());
                tbJctjxxb.setQtpzjg(row.getCell(96).getStringCellValue());
                tbJctjxxb.setQtpzrq(row.getCell(97).getStringCellValue());
                tbJctjxxb.setLsydpzwh(row.getCell(98).getStringCellValue());
                tbJctjxxb.setLsydpwly(row.getCell(99).getStringCellValue());
                tbJctjxxb.setLsydpzmj(row.getCell(100).getStringCellValue());
                tbJctjxxb.setLsydpzjg(row.getCell(101).getStringCellValue());
                tbJctjxxb.setLsydpzrq(row.getCell(102).getStringCellValue());
                tbJctjxxb.setTdgypzwh(row.getCell(103).getStringCellValue());
                tbJctjxxb.setTdgypwly(row.getCell(104).getStringCellValue());
                tbJctjxxb.setTdgypzmj(row.getCell(105).getStringCellValue());
                tbJctjxxb.setTdgypzjg(row.getCell(106).getStringCellValue());
                tbJctjxxb.setTdgypzrq(row.getCell(107).getStringCellValue());
                tbJctjxxb.setXxydpzwh(row.getCell(108).getStringCellValue());
                tbJctjxxb.setXxydpwly(row.getCell(109).getStringCellValue());
                tbJctjxxb.setXxydpzmj(row.getCell(110).getStringCellValue());
                tbJctjxxb.setXxydpzjg(row.getCell(111).getStringCellValue());
                tbJctjxxb.setXxydpzrq(row.getCell(112).getStringCellValue());
                tbJctjxxb.setYspzwh(row.getCell(113).getStringCellValue());
                tbJctjxxb.setYspwly(row.getCell(114).getStringCellValue());
                tbJctjxxb.setYspzmj(row.getCell(115).getStringCellValue());
                tbJctjxxb.setYspzjg(row.getCell(116).getStringCellValue());
                tbJctjxxb.setYspzrq(row.getCell(117).getStringCellValue());
                tbJctjxxb.setQtpdyjsm(row.getCell(118).getStringCellValue());
                tbJctjxxb.setDkbsm(row.getCell(119).getStringCellValue());
                tbJctjxxb.setJcmj(Float.parseFloat((row.getCell(120).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(120).getStringCellValue()));
                tbJctjxxb.setWqtbbh(row.getCell(121).getStringCellValue());
                tbJctjxxb.setBz(row.getCell(122).getStringCellValue());
                tbJctjxxb.setJctbxzgdmj(Float.parseFloat((row.getCell(123).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(123).getStringCellValue()));
                tbJctjxxb.setJctbxznydzmj(Float.parseFloat((row.getCell(124).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(124).getStringCellValue()));
                tbJctjxxb.setDlrdjsydmj(Float.parseFloat((row.getCell(125).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(125).getStringCellValue()));
                tbJctjxxb.setDlrdwlydmj(Float.parseFloat((row.getCell(126).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(126).getStringCellValue()));
                tbJctjxxb.setZjbntmj(Float.parseFloat((row.getCell(127).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(127).getStringCellValue()));
                tbJctjxxb.setMjzbzddsdxjxzqdm(row.getCell(128).getStringCellValue());
                tbJctjxxb.setMjzbzddsdxjxzqmc(row.getCell(129).getStringCellValue());
                tbJctjxxb.setMjzbzddxzjxzqdm(row.getCell(130).getStringCellValue());
                tbJctjxxb.setMjzbzddxzjxzqmc(row.getCell(131).getStringCellValue());
                tbJctjxxb.setMjzbzddcjxzqdm(row.getCell(132).getStringCellValue());
                tbJctjxxb.setMjzbzddcjxzqmc(row.getCell(133).getStringCellValue());
                tbJctjxxb.setNzyjsydxmtb2010zj(row.getCell(134).getStringCellValue());
                tbJctjxxb.setTdzzysxm(row.getCell(135).getStringCellValue());
                tbJctjxxb.setZjggxmcjq(row.getCell(136).getStringCellValue());
                tbJctjxxb.setZjggxmjxq(row.getCell(137).getStringCellValue());
                tbJctjxxb.setGkfqdfkxm(row.getCell(138).getStringCellValue());
                tbJctjxxb.setWlydkfxm(row.getCell(139).getStringCellValue());
                tbJctjxxb.setGdxx(row.getCell(140).getStringCellValue());
                tbJctjxxb.setYsxmxx(row.getCell(141).getStringCellValue());
                tbJctjxxb.setSsnydxx(row.getCell(142).getStringCellValue());
                tbJctjxxb.setXxydxx(row.getCell(143).getStringCellValue());
                tbJctjxxb.setKqxx(row.getCell(144).getStringCellValue());
                tbJctjxxb.setQtkqxx(row.getCell(145).getStringCellValue());
                tbJctjxxb.setSklx(row.getCell(146).getStringCellValue());
                tbJctjxxb.setTskqmj(Float.parseFloat((row.getCell(147).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(147).getStringCellValue()));
                tbJctjxxb.setYjmj(Float.parseFloat((row.getCell(148).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(148).getStringCellValue()));
                tbJctjxxb.setZrbhqxx(row.getCell(149).getStringCellValue());
                tbJctjxxb.setYsxwpdlrdgdmj(Float.parseFloat((row.getCell(150).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(150).getStringCellValue()));
                tbJctjxxb.setYsxwpdlrdnydmj(Float.parseFloat((row.getCell(151).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(151).getStringCellValue()));
                tbJctjxxb.setYsxwpdlrdjsydmj(Float.parseFloat((row.getCell(152).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(152).getStringCellValue()));
                tbJctjxxb.setYsxwpdlrdwlydmj(Float.parseFloat((row.getCell(153).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(153).getStringCellValue()));
                tbJctjxxb.setYsxwpdlrdjbntmj(Float.parseFloat((row.getCell(154).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(154).getStringCellValue()));
                tbJctjxxb.setWsxwpdlrdgdmj(Float.parseFloat((row.getCell(155).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(155).getStringCellValue()));
                tbJctjxxb.setWsxwpdlrdnydmj(Float.parseFloat((row.getCell(156).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(156).getStringCellValue()));
                tbJctjxxb.setWsxwpdlrdjsydmj(Float.parseFloat((row.getCell(157).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(157).getStringCellValue()));
                tbJctjxxb.setWsxwpdlrdwlydmj(Float.parseFloat((row.getCell(158).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(158).getStringCellValue()));
                tbJctjxxb.setWsxwpdlrdstmj(Float.parseFloat((row.getCell(159).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(159).getStringCellValue()));
                tbJctjxxb.setWsxwpdlrdjbntmj(Float.parseFloat((row.getCell(160).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(160).getStringCellValue()));
                tbJctjxxb.setSffgdk(row.getCell(161).getStringCellValue());
                tbJctjxxb.setSkbj(row.getCell(162).getStringCellValue());
                tbJctjxxb.setHfSfwbjxfhxxgcd(row.getCell(163).getStringCellValue());
                tbJctjxxb.setHfDjgptwthbfsftgjzcl(row.getCell(164).getStringCellValue());
                tbJctjxxb.setHfTbwhysmjsfyz(row.getCell(165).getStringCellValue());
                tbJctjxxb.setHfTgzmwjsfkzwxzjsydpdyj(row.getCell(166).getStringCellValue());
                tbJctjxxb.setHfQksmsfhl(row.getCell(167).getStringCellValue());
                tbJctjxxb.setHfSftgzlpwslsj(row.getCell(168).getStringCellValue());
                tbJctjxxb.setHfBz(row.getCell(169).getStringCellValue());
                tbJctjxxb.setWfSfwbjxfhxxgcd(row.getCell(170).getStringCellValue());
                tbJctjxxb.setWfDjgptwthbfsftgjzcl(row.getCell(171).getStringCellValue());
                tbJctjxxb.setWfTbwhysmjsfyz(row.getCell(172).getStringCellValue());
                tbJctjxxb.setWfTgzmwjsfkzwxzjsydpdyj(row.getCell(173).getStringCellValue());
                tbJctjxxb.setWfQksmsfhl(row.getCell(174).getStringCellValue());
                tbJctjxxb.setWfSftgzlpwslsj(row.getCell(175).getStringCellValue());
                tbJctjxxb.setWfSsnydpzsj(row.getCell(176).getStringCellValue());
                tbJctjxxb.setWfSftgxzrmzfcjsyssnyydytdzmcl(row.getCell(177).getStringCellValue());
                tbJctjxxb.setWfLsydpwly(row.getCell(178).getStringCellValue());
                tbJctjxxb.setWfPzwhysmjhlx(row.getCell(179).getStringCellValue());
                tbJctjxxb.setWfSlfwthqk(row.getCell(180).getStringCellValue());
                tbJctjxxb.setWfCcdw(row.getCell(181).getStringCellValue());
                tbJctjxxb.setWfFgdw(row.getCell(182).getStringCellValue());
                tbJctjxxb.setWfBbsxlx(row.getCell(183).getStringCellValue());
                tbJctjxxb.setWfBz(row.getCell(184).getStringCellValue());
                tbJctjxxb.setQtSsnydpzsj(row.getCell(185).getStringCellValue());
                tbJctjxxb.setQtLsydpwly(row.getCell(186).getStringCellValue());
                tbJctjxxb.setQtPzwhysmjhlx(row.getCell(187).getStringCellValue());
                tbJctjxxb.setQtSlfwthqk(row.getCell(188).getStringCellValue());
                tbJctjxxb.setQtSftgxjjcphcl(row.getCell(189).getStringCellValue());
                tbJctjxxb.setQtSfwgbzntnfltnd(row.getCell(190).getStringCellValue());
                tbJctjxxb.setQtBawjsfhl(row.getCell(191).getStringCellValue());
                tbJctjxxb.setQtSftgssnydbacl(row.getCell(192).getStringCellValue());
                tbJctjxxb.setQtSsnydbaclpzsj(row.getCell(193).getStringCellValue());
                tbJctjxxb.setQtSftgbacl(row.getCell(194).getStringCellValue());
                tbJctjxxb.setQtPzsj1(row.getCell(195).getStringCellValue());
                tbJctjxxb.setQtSftgxzrmzfcjsyssnyydytdzmcl(row.getCell(196).getStringCellValue());
                tbJctjxxb.setQtSftglsydpf(row.getCell(197).getStringCellValue());
                tbJctjxxb.setQtSffhsdwbhbz(row.getCell(198).getStringCellValue());
                tbJctjxxb.setQtQksmsfhl(row.getCell(199).getStringCellValue());
                tbJctjxxb.setQtSffhsdwbhrdbz(row.getCell(200).getStringCellValue());
                tbJctjxxb.setQtSftgxxydsx(row.getCell(201).getStringCellValue());
                tbJctjxxb.setQtBz(row.getCell(202).getStringCellValue());
                tbJctjxxb.setHfPzwh(row.getCell(203).getStringCellValue());
                tbJctjxxb.setHfPzxmmc(row.getCell(204).getStringCellValue());
                tbJctjxxb.setHfPzsj(row.getCell(205).getStringCellValue());
                tbJctjxxb.setHfPzzygdmj(Float.parseFloat((row.getCell(206).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(206).getStringCellValue()));
                tbJctjxxb.setHfPzzygdmjdw(row.getCell(207).getStringCellValue());
                tbJctjxxb.setHfZlpwclmc(row.getCell(208).getStringCellValue());
                tbJctjxxb.setHfZlpwlx(row.getCell(209).getStringCellValue());
                tbJctjxxb.setWfPzwh1(row.getCell(210).getStringCellValue());
                tbJctjxxb.setWfPzxmmc1(row.getCell(211).getStringCellValue());
                tbJctjxxb.setWfPzsj1(row.getCell(212).getStringCellValue());
                tbJctjxxb.setWfZlpwlx(row.getCell(213).getStringCellValue());
                String ddd = row.getCell(214).getStringCellValue();
                tbJctjxxb.setWfPzzygdmj(Float.parseFloat((row.getCell(214).getStringCellValue() + "").equals("") ? 0 + "" : row.getCell(214).getStringCellValue()));
                tbJctjxxb.setWfPzzygdmjdw(row.getCell(215).getStringCellValue());
                tbJctjxxb.setWfPzwh2(row.getCell(216).getStringCellValue());
                tbJctjxxb.setWfPzxmmc2(row.getCell(217).getStringCellValue());
                tbJctjxxb.setWfPzsj2(row.getCell(218).getStringCellValue());
                tbJctjxxb.setWfZlpwclmc(row.getCell(219).getStringCellValue());
                tbJctjxxb.setQtPzwh(row.getCell(220).getStringCellValue());
                tbJctjxxb.setQtPzxmmc(row.getCell(221).getStringCellValue());
                tbJctjxxb.setQtPzsj2(row.getCell(222).getStringCellValue());
                tbJctjxxb.setQtSftgxxydsxclmc(row.getCell(223).getStringCellValue());
                tbJctjxxb.setQtSftgxxydsxpfsj(row.getCell(224).getStringCellValue());
                tbJctjxxb.setQtTgbawjsj(row.getCell(225).getStringCellValue());
                tbJctjxxb.setQtClmc(row.getCell(226).getStringCellValue());
                tbJctjxxb.setZzjglb(row.getCell(227).getStringCellValue());
                tbJctjxxb.setJlpf(row.getCell(228).getStringCellValue());
                tbJctjxxb.setDwShr(row.getCell(229).getStringCellValue());
                tbJctjxxb.setDwShrxm(row.getCell(230).getStringCellValue());
                tbJctjxxb.setDwTjsj(row.getCell(231).getStringCellValue());
                tbJctjxxb.setJlShr(row.getCell(232).getStringCellValue());
                tbJctjxxb.setJlShrxm(row.getCell(233).getStringCellValue());
                tbJctjxxb.setJlTjsj(row.getCell(234).getStringCellValue());
                tbJctjxxb.setJgbz(row.getCell(235).getStringCellValue());
                tbJctjxxb.setYear(sYear);
                tbJctjxxb.setMonth(sMonth);
                //遍历所有的列
//                for (Cell cell : row) {
//                    System.out.print(cell.getStringCellValue() + " ");
//                }
                jctjxxbDaoList.add(tbJctjxxb);
            }
            boolean bResult = InsertBatch(jctjxxbDaoList);
            if (bResult)
                return "";
            else
                return "入库失败！";
        } catch (Exception ex) {
            return ex.getMessage();
        }
    }

    @Autowired
    private SqlSessionFactory sqlSessionFactory;

    @Transactional
    public boolean InsertBatch(List<TbJctjxxbDao> jctjxxbDaoList) {
        SqlSession sqlSession = null;
        try {
            //使用批处理
            sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
            JdfkStatisticsMapper jdfkMapper = sqlSession.getMapper(JdfkStatisticsMapper.class);
            jctjxxbDaoList.stream().forEach(jctjxxbDao -> jdfkMapper.insert(jctjxxbDao));
            sqlSession.commit();
            return true;
        } catch (Exception ex) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            ex.printStackTrace();
            return false;
        } finally {
            // 确保SqlSession被关闭
            if (sqlSession != null) {
                sqlSession.close();
            }
        }
    }
}
